import java.awt.Canvas;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import tiled.simple.core.Animation;
import tiled.simple.core.Map;
import tiled.simple.core.Renderer;


public class WindowFrame extends Frame implements Renderer{
	private static final long serialVersionUID = 2L;

	private Closer Handler;
	
    public Map map;
    public Animation animation;
    
	Canvas canvas = new Canvas();
	
    @SuppressWarnings("deprecation")
	WindowFrame () {
        Handler = new Closer ();
        setTitle ("Animation test");
        setSize (1024,1024);
        addWindowListener (Handler);
        show ();
    }

    int i=0;
    public void paint(Graphics g) {
    	g.setColor(new Color(64,64,64));
    	g.drawLine(0, 0, 100, 100);
    	this.g=g;
    	
    	g.setColor(new Color(0,0,0));
    	g.fillRect(0, 0, 512, 512);
    	
    	animation.renderSprite(map,this, -3);
    	p+=40;
    	animation.renderSprite(map,this, -2);
    	p+=40;
    	animation.renderSprite(map,this, -1);
    	p+=40;
    	animation.renderSprite(map,this, 0);
    	p+=40;
    	animation.renderSprite(map,this, 1);
    	p+=40;
    	animation.renderSprite(map,this, 2);
    	p+=40;
    	animation.renderSprite(map,this, 3);
    	p+=40;
    	animation.renderSprite(map,this, 4);
    	p+=40;
    	animation.renderSprite(map,this, 5);
    	p+=40;
    	animation.renderSprite(map,this, 6);
    	p+=40;
    	animation.renderSprite(map,this, 7);
    	p+=40;
    	animation.renderSprite(map,this, 8);
    	p+=40;
    	animation.renderSprite(map,this, 9);
    	p+=40;
    	animation.renderSprite(map,this, 10);
    	p+=40;
    	//map.render(this);
    	//map.render(this);
    }
    
    Graphics g;
    
	public void loadImage(String source) {
	}

	int p=0;
	
	public void putImage(String source, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh) {
		
		Image img = null;
		try {
			img = ImageIO.read(new File(source));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		g.drawImage(img, p+100+dx,100+ dy, p+100+dx+dw, 100+dy+dh, sx, sy, sx+sw, sy+sh, this);

	}


}